package home_page

import (
	"api/internal/respons"
	"context"
	"homepage_srv/homepage"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HotWordSearchLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHotWordSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HotWordSearchLogic {
	return &HotWordSearchLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HotWordSearchLogic) HotWordSearch(req *types.HotWordSearchRequest) (resp *types.Response, err error) {
	search, err := l.svcCtx.HomepageGrpc.HotWordSearch(l.ctx, &homepage.HotWordSearchRequest{
		HouId: req.HouId,
	})

	if err != nil {
		return respons.Error(400, "热词搜索异常", nil), err
	}
	return respons.Success(search), nil
}
